import Vue from 'vue'
import VueRouter from 'vue-router'

import userLayout from './../pages/user'
import userLogin from "../pages/user/login/Login";
import Home from "../pages/user/home/Home";
import Search from "../pages/user/search/Search";
import Mine from "../pages/user/mine/Mine";
import BikeDetail from "../pages/user/bikeDetail/BikeDetail";
import ArticleDetail from "../pages/user/articleDetail/ArticleDetail";

import adminLayout from './../pages/admin'
import adminLogin from "../pages/admin/login/Login";
import articleManage from "../pages/admin/articleManage/articleManage";
import userManage from "../pages/admin/userManage/userManage";
import messageManage from "../pages/admin/messageManage/messageManage";
import orderManage from "../pages/admin/orderManage/orderManage";
import bikeManage from "../pages/admin/bikeManage/bikeManage";

// import config from "../config";

Vue.use(VueRouter);

const router = new VueRouter({
  routes: [
    {
      path: '/user',
      component: userLayout,
      children: [
        { path: 'home', component: Home },
        { path: 'articleDetail/:articleId', component: ArticleDetail },
        { path: 'search', component: Search },
        { path: 'mine', component: Mine },
        { path: 'bikeDetail/:bikeId', component: BikeDetail },
        { path: '/user', redirect: '/user/home' },
      ]
    },
    { path: '/login', component: userLogin },

    {
      path: '/admin',
      component: adminLayout,
      children: [
        { path: 'articleManage', component: articleManage },
        { path: 'userManage', component: userManage },
        { path: 'messageManage', component: messageManage },
        { path: 'orderManage', component: orderManage },
        { path: 'bikeManage', component: bikeManage },
        { path: '/admin', redirect: '/admin/bikeManage' },
      ]
    },
    { path: '/adminLogin', component: adminLogin },
    {//默认路由
      path: '/',
      redirect: '/admin'
    }
  ]
});

export default router;
